// import { Socket, createServer } from "node:net"

// const client = new Socket()
// client.on("data", (data) => {
//     console.log(data);
// })
// client.connect("1251", "::1", () => {
//     console.log("connected to server")

//     // client.write(new Uint8Array([0xfa, 0xaf, 0x01, 12, 87, 40, 1, 0xfe, 0xef, 10]));
//     // client.write(new Uint8Array([0xfa, 0xaf, 0x02, 12, 87, 40, 1, 0xfe, 0xef, 10]));
//     // client.write(new Uint8Array([0xfa, 0xaf, 0x03, 12, 87, 40, 1, 0xfe, 0xef, 10]));
//     // client.write(new Uint8Array([0xfa, 0xaf, 0x04, 12, 87, 40, 1, 0xfe, 0xef, 10]));
// })

// const server = createServer((socket) => {
//     socket.on("data", (data) => {
//         console.log(data);
//     })
//     // setTimeout(() => {
//     //     socket.write(new Uint8Array([0xfa, 0xaf, 0x01, 12, 87, 40, 1, 0xfe, 0xef, 10]));
//     //     socket.write(new Uint8Array([0xfa, 0xaf, 0x02, 12, 87, 40, 1, 0xfe, 0xef, 10]));
//     //     socket.write(new Uint8Array([0xfa, 0xaf, 0x03, 12, 87, 40, 1, 0xfe, 0xef, 10]));
//     //     socket.write(new Uint8Array([0xfa, 0xaf, 0x04, 12, 87, 40, 1, 0xfe, 0xef, 10]));
//     // }, 1000)

// })

// server.listen(1251, "::1")


import { createSocket } from "node:dgram"

const server = createSocket("udp4")
server.on("message", (data, rinfo) => {
    console.log(data, rinfo);
    setTimeout(() => {
        server.send(data, rinfo.port, rinfo.address)
    }, 100);
})

server.send("hello", 54028, "0.0.0.0")